/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.prototype.vaadin;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Cmd
 */
public class AppProperties {
    /**.
     * @param prop
     * @param as
     */
     private Properties prop;
     private FileInputStream as;

     /**.
      * Constructor
      * @param path path of the properties file on the disk
      * @throws IOException
      */
     public AppProperties(final String path) throws IOException {
        this.prop = new Properties();
        try {
            this.as = new FileInputStream(path);
            prop.load(as);
        } catch (IOException ex) {
            ex.getMessage();
        }
     }

     /**.
      * take in a propkey and return the value associate
      * @param propkey
      * @return the value of the key in parameter
      * @throws Exception
      */
     public String getPropValue(String propkey) {
         String key = "";
         try {
            if (prop.containsKey(propkey)) {
                key = prop.getProperty(propkey);
            }
         } catch (Exception ex) {
            ex.getMessage();
         }
         return key;
     }

     /**.
      * clear the attribut prop
      */
     public void clearProperties() {
        try {
            prop.clear();
            as.close();
        } catch (IOException ex) {
            Logger.getLogger(AppProperties.class.getName())
                    .log(Level.SEVERE, null, ex);
        }
     }
}
